
#ifndef FsCmd_h__
#define FsCmd_h__

#ifdef __cplusplus
extern "C" {
#endif

/* File status structure (FILINFO) */
#define	_USE_LFN	1

#pragma	pack(1)
typedef struct {
	DWORD	fsize;			/* File size */
	WORD	fdate;			/* Last modified date */
	WORD	ftime;			/* Last modified time */
	BYTE	fattrib;		/* Attribute */
	TCHAR	fname[13];		/* Short file name (8.3 format) */
#if _USE_LFN
	TCHAR	lfname[256];			/* Pointer to the LFN buffer */
	UINT 	lfsize;			/* Size of LFN buffer in TCHAR */
#endif
} FILINFO;
#pragma	pack()

/* File access control and file status flags (FIL.flag) */

#define	FA_READ				0x01
#define	FA_OPEN_EXISTING	0x00
#define FA__ERROR			0x80


#define	FA_WRITE			0x02
#define	FA_CREATE_NEW		0x04
#define	FA_CREATE_ALWAYS	0x08
#define	FA_OPEN_ALWAYS		0x10
#define FA__WRITTEN			0x20
#define FA__DIRTY			0x40


BOOL fs_open(HANDLE *hFile, const TCHAR *fileName, BYTE modeFlags);
BOOL fs_close(HANDLE hFile);
BOOL fs_read(HANDLE hFile, BYTE *buf, UINT sizeBuf, UINT *count);
BOOL fs_write(HANDLE hFile, BYTE *buf, UINT sizeBuf, UINT *count);

BOOL fs_getfree(DWORD *dwFree);

int	 fs_get_filescount(TCHAR *path);
BOOL fs_listdir(TCHAR *path, FILINFO *pHead);
BOOL fs_createdir(const TCHAR *path);
BOOL fs_delete(const TCHAR *path);
BOOL fs_rename (const TCHAR* src, const TCHAR* des);
BOOL fs_getattr(const TCHAR* path, FILINFO* filinfo);

BOOL fs_format(CHAR vol);

BOOL fs_opendev(CHAR vol);
BOOL fs_closedev();

BOOL fs_get_diskSN(CHAR vol, CHAR *pcSN, WORD wLen);
BOOL fs_get_disksize(CHAR vol, DWORD *dwDiskSize);

BOOL fs_isformat();

BOOL fs_VerifyPassword(CHAR vol, CHAR *pcPassword);
BOOL fs_ChangePassword(CHAR vol, CHAR *pcNewPassword);
int  fs_GetTryRemaining(CHAR vol);
int  fs_GetError(CHAR vol);

#ifdef __cplusplus
}
#endif

#endif // FsCmd_h__
